home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / bipl.zip / PROGS.ZIP / SHUFFILE.ICN < prev    next >
Text File  |  1992-09-28  |  2KB  |  61 lines

  1. ############################################################################
  2. #
  3. #    File:     shuffile.icn
  4. #
  5. #    Subject:  Program to shuffle lines in a file
  6. #
  7. #    Author:   Ralph E. Griswold
  8. #
  9. #    Date:     June 10, 1988
  10. #
  11. ###########################################################################
  12. #  
  13. #     This program writes a version of the input file with the lines
  14. #  shuffled.  For example, the result of shuffling
  15. #  
  16. #                   On the Future!-how it tells
  17. #                   Of the rapture that impells
  18. #                  To the swinging and the ringing
  19. #                   Of the bells, bells, bells-
  20. #                Of the bells, bells, bells, bells,
  21. #                          Bells, bells, bells-
  22. #            To the rhyming and the chiming of the bells!
  23. #  
  24. #  is
  25. #  
  26. #            To the rhyming and the chiming of the bells!
  27. #                  To the swinging and the ringing
  28. #                          Bells, bells, bells-
  29. #                   Of the bells, bells, bells-
  30. #                   On the Future!-how it tells
  31. #                Of the bells, bells, bells, bells,
  32. #                   Of the rapture that impells
  33. #  
  34. #  Option: The option -s n sets the seed for random generation to n.
  35. #  The default seed is 0.
  36. #  
  37. #  Limitation:
  38. #
  39. #     This program stores the input file in memory and
  40. #  shuffles pointers to the lines; there must be enough memory
  41. #  available to store the entire file.
  42. #  
  43. ############################################################################
  44. #
  45. #  Links: options, shuffle
  46. #
  47. ############################################################################
  48.  
  49. link options, shuffle
  50.  
  51. procedure main(args)
  52.    local opts, a
  53.  
  54.    opts := options(args, "s+")
  55.    &random := \opts["s"]
  56.  
  57.    a := []
  58.    every put(a,!&input)
  59.    every write(!shuffle(a))
  60. end
  61.